<?php

class NavigationView {
	//Our action consts
	const controller = "Action";
	const logOutAction = "Logout";
	const userId = "userId";

	//Fileupload message
	const Code = "MessageCode";
	const FileUploadMessageCode = "FileUpload";
	const RemovedUserId = "RemovedUserId";
	const RemoveThisImage = "RemoveImageName";
	const removeImgClicked = "RemoveSubmit";

	//Signupmassage
	const username = "User";

	//Logout
	const logOut = "Logout";

	//Our different Controllers
	const login = "LoginController";
	const signup = "SignUpController";
	const showUserController = "ShowUserController";
	const learnMore = "More";
	
	/**
	 * Function to generate HTML for JS slider, If not Mobile visitor, then it will return empty string
	 * @access public
	 * @param -
	 * @return HTML
	 */
	public static function GenerateJSSlider() {
		$detect = new MobileDetect();
		if(!$detect -> isMobile()){	
			return "<div id='container'>
				
					<div id='header'>
						<h3>Store your photos &amp; and share with other users...</h3>
					</div>
				
					<div id='content'>
						<div id='slider'>
							<ul>				
								<li><a href='?" . NavigationView::controller . "=" . NavigationView::login . "'><img src='images/AutumnLeaves.jpg' alt='AutumnLeaves' /></a></li>
								<li><a href='?" . NavigationView::controller . "=" . NavigationView::login . "'><img src='images/Creek.jpg' alt='Creek' /></a></li>
								<li><a href='?" . NavigationView::controller . "=" . NavigationView::login . "'><img src='images/DesertLandscape.jpg' alt='DesertLandscape' /></a></li>
								<li><a href='?" . NavigationView::controller . "=" . NavigationView::login . "'><img src='images/Dock.jpg' alt='Dock' /></a></li>
								<li><a href='?" . NavigationView::controller . "=" . NavigationView::login . "'><img src='images/ForestFlowers.jpg' alt='ForestFlowers' /></a></li>			
							</ul>
						</div>
					</div>
					
			</div>";
		}
		return "";
	}
	
	/**
	 * Function to generate the about page
	 * @access public 
	 * @param -
	 * @return HTML div with content
	 */
	public static function generateAboutDiv() {
		return "<div class='aboutDiv'>
			<h1>About IMG-YAIC</h1>
			<p>Site created as a project in the 'Object oriented and test driven development with PHP' - course at the Linnaeus University</p>
			<p>The site was created using:</p>
			<ul>
				<li>PHP with an Model View Controller architecture</li>
				<li>MySQL</li>
				<li>JavaScript</li>
				<li>JQuery</li>
			</ul>
		</div>";
	}
	
	/**
	 * Function to get active user from URL
	 * @access public
	 * @param -
	 * @return UserId
	 */
	public static function getActiveUser() {
		if (isset($_GET[self::userId])) {
			return $_GET[self::userId];
		}
		return false;
	}
	
	/**
	 * Function to read URL and return active Controller
	 * @access public
	 * @param -
	 * @return string: active controller
	 */
	public static function getActiveController() {
		if (isset($_GET[self::controller])) {
			return $_GET[self::controller];
		}
		return;
	}
	
	/**
	 * Function to redirect user
	 * @access Public
	 * @param String location
	 * @return -
	 */
	public static function setHeadeLocation($a_location){
		header("Location: $a_location");
	}
	
	/**
	 * Function to generate HTML menu, will determine what kind of menu to return
	 * @access public
	 * @param UserObject or null
	 * @return - HTML
	 */
	public static function getMenu($user) {
		if (is_object($user)) {
			if ($user -> IsAdmin) {
				return "<ul>
						<li><a href='?" . self::controller . "=" . self::login . "'>Adminview</a></li>
						<li><p>|</p></li>
						<li><a href='?" . self::controller . "=" . self::login . "&" . self::logOutAction . "=" . self::logOut . "'>Logout</a></li>
					</ul>";
			} else {
				return "<ul>
						<li><a href='?" . self::controller . "=" . self::login . "'>Home</a></li>
						<li><p>|</p></li>
						<li><a href='?" . self::controller . "=" . self::showUserController . "'>All Users</a></li>
						<li><p>|</p></li>
						<li><a href='?" . self::controller . "=" . self::login . "&" . self::logOutAction . "=" . self::logOut . "'>Logout</a></li>
					</ul>";
			}
		} else {
			return "<ul>
						<li><a href='?" . self::controller . "=" . self::login . "'>Log in</a></li>
						<li><p>|</p></li>
						<li><a href='?" . self::controller . "=" . self::signup . "'>Sign up</a></li>
						<li><p>|</p></li>
						<li><a href='?" . self::controller . "=" . self::learnMore . "'>Learn More</a></li>
					</ul>";
		}
	}

}
